<template>
  <div>
       <van-icon :color="value===1?'red' : '#777'"
       :name="value===1?'good-job':'good-job-o'"
       @click="onClick"/>
  </div>
</template>

<script>
import { addLike, deleteLike } from '@/api/article.js'
export default {
  name: 'LikeArticle',
  components: {},
  props: {
    value: [Number],
    articleId: [String, Number, Object]
  },
  methods: {
    onClick () {
      if (this.value === 1) {
        deleteLike(this.articleId)
      } else {
        addLike(this.articleId)
      }
      this.$emit('input', this.value === 1 ? 0 : 1)
      this.$toast.success('操作成功')
    }
  }
}
</script>

<style>

</style>